package acm.pta14;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class 盲盒包装流水线 {
    static int[] map=new int[100001];
    static BitSet bitSet=new BitSet(100001);
    public static void main(String[] args) {
        Reader sc=new Reader();
        int n=sc.nextInt();
        int k=sc.nextInt();
        int len=n/k;
        Stack<Integer>[] stack=new Stack[len];
        for (int i = 0; i < len; i++) {
            stack[i]=new Stack<>();
            for (int j = 0; j < k; j++) {
                stack[i].push(sc.nextInt());
            }
        }
        for (int i = 0; i < len; i++) {
            for (int j = 0; j < k; j++) {
                Integer pop = stack[i].pop();
                bitSet.set(pop);
                map[pop]=sc.nextInt();
            }
        }
        n = sc.nextInt();
        while (n-- > 0) {
            int i=sc.nextInt();
            if (bitSet.get(i)) {
                System.out.println(map[i]);
            } else {
                System.out.println("Wrong Number");
            }
        }
    }
    static
    class Reader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {    //内存中没有
                String nextLine = innerNextLine();
                if (nextLine == null) {     //且没有下一行
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);  //读入一行
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");    //清空内存中的字符
            return innerNextLine();
        }
        public void clear(){
            tokenizer = new StringTokenizer("");
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }
//    public BigInteger nextBigInt() {
//        return new BigInteger(next());
//    }
    }

}
